package com.liuzh.deviceinfo.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.view.View;

public class ScreenSaturationView extends View {
    public int a;
    public int b;
    public Paint c = new Paint(1);
    public Paint d;
    public int e;

    public ScreenSaturationView(Context context) {
        super(context);
        Paint paint = new Paint(1);
        this.d = paint;
        this.e = -1;
        paint.setColor(-16777216);
    }

    public void onDraw(Canvas canvas) {
        int i;
        int i2;
        Canvas canvas2 = canvas;
        canvas2.drawColor(this.e);
        int i3 = this.a - 60;
        int i4 = this.b - 60;
        if (i3 > i4) {
            i = 7;
            i2 = 4;
        } else {
            i = 4;
            i2 = 7;
        }
        int i5 = i3 / i;
        int i6 = i4 / i2;
        int min = (int) (((double) Math.min(i5, i6)) * 0.6d);
        int i7 = (i5 - min) / 2;
        int i8 = (i6 - min) / 2;
        this.d.setTextSize((float) (min / 7));
        int textSize = (int) ((this.d.getTextSize() / 2.0f) + ((float) ((min * 6) / 5)));
        i3 = 0;
        int i9 = 0;
        while (i9 < i2) {
            int i10;
            int i11 = 0;
            while (i11 < i) {
                int i12 = ((i11 * i5) + 30) + i7;
                i4 = ((i9 * i6) + 30) + i8;
                i10 = textSize;
                textSize = this.e == -1 ? (255 - (i11 * i9)) - i3 : (i11 * i9) + i3;
                int i13 = i3 + 3;
                this.c.setColor(Color.rgb(textSize, textSize, textSize));
                this.c.setStyle(Style.STROKE);
                this.c.setStrokeWidth((float) (min / 5));
                float f = (float) i12;
                float f2 = (float) (i12 + min);
                int i14 = i13;
                int i15 = i4;
                int i16 = i12;
                int i17 = i11;
                float f3 = f2;
                int i18 = i9;
                float f4 = f;
                canvas.drawRect(f, (float) i4, f3, (float) (i4 + min), this.c);
                this.c.setStyle(Style.FILL);
                i3 = min / 4;
                float f5 = (float) (i16 + i3);
                float f6 = (float) (i15 + i3);
                i3 = (min * 3) / 4;
                canvas.drawRect(f5, f6, (float) (i16 + i3), (float) (i15 + i3), this.c);
                String valueOf = String.valueOf(((i18 * i) + i17) + 1);
                canvas2.drawText(valueOf, ((((float) min) - this.d.measureText(valueOf)) / 2.0f) + f4, (float) (i15 + i10), this.d);
                i11 = i17 + 1;
                textSize = i10;
                i9 = i18;
                i3 = i14;
            }
            i10 = textSize;
            i9++;
        }
    }

    public void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        this.a = i;
        this.b = i2;
    }
}
